﻿using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;

namespace Kaleida.ServiceMonitor.UI
{
    public partial class NewScriptDialog : Form
    {
        public NewScriptDialog()
        {
            InitializeComponent();
        }

        private void tbScriptName_KeyPress(object sender, KeyPressEventArgs e)
        {
            bool nonFilenameCharacter = Path.GetInvalidFileNameChars().Contains(e.KeyChar) ||
                                        Path.GetInvalidPathChars().Contains(e.KeyChar);

            if(!Char.IsControl(e.KeyChar) && nonFilenameCharacter)
            {
                e.Handled = true;
            }
        }

        public string ScriptName
        {
            get { return tbScriptName.Text; }
            set { tbScriptName.Text = value; }
        }
    }
}
